package com.wuyan.locationdog.adapter

import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.arcsoft.commonbase.bean.TeamMember
import com.arcsoft.commonbase.ext.ImageOptions
import com.arcsoft.commonbase.ext.loadImage
import com.arcsoft.commonbase.ext.radius
import com.arcsoft.commonbase.utils.getTestDataList
import com.blankj.utilcode.util.ColorUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R
import com.wuyan.locationdog.view.TeamGridView


class TeamDetailPersonListAdapter(@LayoutRes layoutResId: Int, data: MutableList<TeamMember>?) :
    BaseQuickAdapter<TeamMember, BaseViewHolder>(layoutResId, data) {


    override fun convert(holder: BaseViewHolder, item: TeamMember) {
        holder.apply {
            getView<ImageView>(R.id.userAvatar).apply {
                if (holder.adapterPosition == 0) {
                    setImageResource(R.mipmap.team_add_person)
                } else {
                    loadImage(item.userAvatar, ImageOptions().apply {
                        placeholder = com.arcsoft.commonbase.R.mipmap.def_dog
                        error = com.arcsoft.commonbase.R.mipmap.def_dog
                        fallback = com.arcsoft.commonbase.R.mipmap.def_dog
                    })
                }
                radius(6F)
            }

            if (item.ifSelf) {
                getView<TextView>(R.id.nickName).setText("本人")
            } else {
                getView<TextView>(R.id.nickName).setText(item.nickName)
            }
            if (item.isSelect) {
                holder.setBackgroundColor(R.id.userAvatar, ColorUtils.getColor(com.arcsoft.commonbase.R.color.text_color_selected))
                holder.setTextColorRes(R.id.nickName, com.arcsoft.commonbase.R.color.text_color_selected)
            } else {
                holder.setBackgroundColor(R.id.userAvatar, 0)
                holder.setTextColorRes(R.id.nickName, com.arcsoft.commonbase.R.color.text_color_unselected)
            }

        }
    }
}


